package com.uplooking.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.uplooking.pojo.GoodVO;
import com.uplooking.service.ShopService;

@RestController
public class ShopController {
	
	@Autowired
	private ShopService shopService;
	
	@GetMapping(value="/shop/type/list")
	public Object typeList() {
		return shopService.getTypeList();
	}
	
	@GetMapping(value="/shop/good/list/{page}/{size}/{shop}")
	public Object goodList(@PathVariable(name="page")int page,
			@PathVariable(name="size")int size,
			@PathVariable(name="shop")String shop) {
		return shopService.getGoodList(shop, page, size);
	}
	
	@PostMapping(value="/shop/add/good")
	public Object addGood(GoodVO goodVO,MultipartFile picture) throws Exception {
		return shopService.addGood(goodVO, picture);
	}
	
	@GetMapping(value="/shop/updown/{no}")
	public Object upDown(@PathVariable(name="no")String no) throws Exception {
		return shopService.updownGood(no);
	}
	
	@GetMapping(value="/shop/order/list/{page}/{size}/{shop}")
	public Object orderList(@PathVariable(name="page")int page,
			@PathVariable(name="size")int size,
			@PathVariable(name="shop")String shop) {
		return shopService.getOrderList(shop, page, size);
	}
}
